using SM;
using SS;
using System;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Windows.Forms;
namespace TVSGPP.func
{
	public class frmSelectPacket : Form
	{
		public string pid = "";
		public string packet = "";
		private Func objFunc = new Func();
		private IContainer components = null;
		private Grid dgvPacket;
		private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
		public frmSelectPacket()
		{
			this.InitializeComponent();
		}
		private void frmSelectPacket_Load(object sender, EventArgs e)
		{
			this.dgvPacket.AutoGenerateColumns = false;
			SqlConnection sqlConnection = new SqlConnection(this.objFunc.strConnectionString);
			SqlCommand selectCommand = new SqlCommand("SELECT DISTINCT [Packet] FROM [TabDetailBill] WHERE [Pid] = " + this.pid, sqlConnection);
			SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(selectCommand);
			DataSet dataSet = new DataSet();
			sqlConnection.Open();
			sqlDataAdapter.Fill(dataSet);
			this.dgvPacket.DataSource = dataSet.Tables[0];
			sqlConnection.Close();
			sqlConnection.Dispose();
			sqlDataAdapter.Dispose();
			dataSet.Dispose();
		}
		private void dgvPacket_KeyPress(object sender, KeyPressEventArgs e)
		{
			if (e.KeyChar == '\r')
			{
				base.Close();
			}
		}
		private void dgvPacket_CellEnter(object sender, DataGridViewCellEventArgs e)
		{
			try
			{
				this.packet = this.dgvPacket.Rows[e.RowIndex].Cells[0].Value.ToString();
			}
			catch
			{
			}
		}
		private void dgvPacket_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
		{
			base.Close();
		}
		protected override void Dispose(bool disposing)
		{
			if (disposing && this.components != null)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}
		private void InitializeComponent()
		{
			DataGridViewCellStyle dataGridViewCellStyle = new DataGridViewCellStyle();
			this.dgvPacket = new Grid();
			this.dataGridViewTextBoxColumn1 = new DataGridViewTextBoxColumn();
			((ISupportInitialize)this.dgvPacket).BeginInit();
			base.SuspendLayout();
			this.dgvPacket.AllowUserToAddRows = false;
			this.dgvPacket.AllowUserToDeleteRows = false;
			this.dgvPacket.AllowUserToOrderColumns = true;
			this.dgvPacket.AllowUserToResizeColumns = false;
			this.dgvPacket.AllowUserToResizeRows = false;
			dataGridViewCellStyle.BackColor = Color.FromArgb(192, 255, 255);
			dataGridViewCellStyle.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.dgvPacket.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle;
			this.dgvPacket.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left);
			this.dgvPacket.BackgroundColor = Color.White;
			this.dgvPacket.BorderStyle = BorderStyle.Fixed3D;
			this.dgvPacket.ColumnHeadersHeight = 26;
			this.dgvPacket.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
			this.dgvPacket.Columns.AddRange(new DataGridViewColumn[]
			{
				this.dataGridViewTextBoxColumn1
			});
			this.dgvPacket.Cursor = Cursors.Hand;
			this.dgvPacket.EnableHeadersVisualStyles = false;
			this.dgvPacket.Location = new Point(2, 2);
			this.dgvPacket.MultiSelect = false;
			this.dgvPacket.Name = "dgvPacket";
			this.dgvPacket.ReadOnly = true;
			this.dgvPacket.RowHeadersVisible = false;
			this.dgvPacket.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing;
			this.dgvPacket.RowTemplate.DefaultCellStyle.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.dgvPacket.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
			this.dgvPacket.Size = new Size(279, 362);
			this.dgvPacket.TabIndex = 40;
			this.dgvPacket.CellDoubleClick += new DataGridViewCellEventHandler(this.dgvPacket_CellDoubleClick);
			this.dgvPacket.CellEnter += new DataGridViewCellEventHandler(this.dgvPacket_CellEnter);
			this.dgvPacket.KeyPress += new KeyPressEventHandler(this.dgvPacket_KeyPress);
			this.dataGridViewTextBoxColumn1.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
			this.dataGridViewTextBoxColumn1.DataPropertyName = "Packet";
			this.dataGridViewTextBoxColumn1.HeaderText = "Lô hàng";
			this.dataGridViewTextBoxColumn1.MinimumWidth = 120;
			this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
			this.dataGridViewTextBoxColumn1.ReadOnly = true;
			base.AutoScaleDimensions = new SizeF(7f, 15f);
			//base.AutoScaleMode = AutoScaleMode.Font;
			base.ClientSize = new Size(284, 366);
			base.Controls.Add(this.dgvPacket);
			this.Cursor = Cursors.Hand;
			this.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
			//base.Icon = (Icon)componentResourceManager.GetObject("$this.Icon");
			this.MaximumSize = new Size(300, 400);
			this.MinimumSize = new Size(300, 400);
			base.Name = "frmSelectPacket";
			base.ShowInTaskbar = false;
			base.StartPosition = FormStartPosition.CenterScreen;
			this.Text = " .: Chọn lô hàng";
			base.Load += new EventHandler(this.frmSelectPacket_Load);
			((ISupportInitialize)this.dgvPacket).EndInit();
			base.ResumeLayout(false);
		}
	}
}
